class BuildRunsController < ApplicationController
  class TmpClass
    attr_writer :id,:name
    attr_reader :id,:name
  end
  
  def index
    list
    render :action => 'list'
  end

  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }

  def list
    @title1 = 'Build runs'
    @url1 = '/build_runs/'
    @build_run_pages, @build_runs = paginate :build_runs, :per_page => 10
  end

  def show
    @title1 = 'Build runs'
    @url1 = '/build_runs/'
    @title2 = params[:id]
    @url2 = "/build_runs/show/#{params[:id]}"
    @build_run = BuildRun.find(params[:id])
    
    dir = "repository/builds/#{@build_run.build_type.name}-#{@build_run.build_type.architecture.name}/#{@build_run.id}/"
    
    begin
      config_cmd = File.open dir+"configure.cmd"
      @config_cmd = config_cmd.read
      config_cmd.close
    rescue
      @config_cmd = ""
    end
    
    begin
      config_out = File.open dir+"configure.out"
      @config_out = config_out.read.chomp
      config_out.close
    rescue
      @config_out = ""
    end
    
    begin
      config_err = File.open dir+"configure.err"
      @config_err = config_err.read.chomp
      config_err.close
    rescue
      @config_err = ""
    end
    
    begin
      make_cmd = File.open dir+"make.cmd";
      @make_cmd = make_cmd.read.chomp
      make_cmd.close
    rescue
      @make_cmd = ""
    end
    
    begin
      make_out = File.open dir+"make.out"
      @make_out = make_out.read.chomp
      make_out.close
    rescue
      @make_out = ""
    end
    
    begin
      make_err = File.open dir+"make.err"
      @make_err = make_err.read.chomp
      make_err.close
    rescue
      @make_err = ""
    end
  end

end
